﻿Public Class Configuraciones 

    
    Private Sub Configuraciones_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ''TODO: This line of code loads data into the 'DbFireAndIceDataSet.deduccionesconfig' table. You can move, or remove it, as needed.
        Me.DeduccionesconfigTableAdapter.Fill(Me.DbFireAndIceDataSet.deduccionesconfig)

        'If modificar.Text = "Actualizar" Then
        '    agregar.Enabled = False
        '    modificar.Enabled = True
        'End If


        'Dim TotalResgistro As Integer = DeduccionesconfigTableAdapter.ScalarQueryContarRegistrosEnLaTabla
        'MsgBox(TotalResgistro)
        'If TotalResgistro = 0 Then
        '    agregar.Enabled = True
        'Else

        '    Me.DeduccionesconfigTableAdapter.Fill(Me.DbFireAndIceDataSet.deduccionesconfig)
        '    modificar.Enabled = True
        'End If

    End Sub
    Private Sub DeduccionesconfigBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) Handles DeduccionesconfigBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.DeduccionesconfigBindingSource1.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbFireAndIceDataSet)

    End Sub


    Private Sub guardar_Click(sender As System.Object, e As System.EventArgs) Handles guardar.Click

        guardar.Enabled = False
        GroupControl1.Enabled = False
        GroupControl2.Enabled = False
        agregar.Enabled = True
        Dim TotalResgistro As Integer = DeduccionesconfigTableAdapter.ScalarQueryContarRegistrosEnLaTabla
        MsgBox(TotalResgistro)
        If TotalResgistro = 0 Then

            DeduccionesconfigTableAdapter.InsertDeduccionesConfiguracionesQuery(Val(IhssTextEdit.Text), Val(FosoviTextEdit.Text), Val(RapTextEdit.Text), Val(IsrTextEdit.Text), Convert.ToBoolean(IhssestadoCheckBox.CheckState), Convert.ToBoolean(FosoviestadoCheckBox.CheckState), Convert.ToBoolean(RapestadoCheckBox.CheckState), Convert.ToBoolean(IsrestadoCheckBox.CheckState))
            DeduccionesconfigBindingNavigatorSaveItem.PerformClick()
        End If

        If TotalResgistro > 0 Then
            DeduccionesconfigTableAdapter.UpdateDeduccionesConfiguracionesQuery(Val(IhssTextEdit.Text), Val(FosoviTextEdit.Text), Val(RapTextEdit.Text), Val(IsrTextEdit.Text), Convert.ToBoolean(IhssestadoCheckBox.CheckState), Convert.ToBoolean(FosoviestadoCheckBox.CheckState), Convert.ToBoolean(RapestadoCheckBox.CheckState), Convert.ToBoolean(IsrestadoCheckBox.CheckState))
            Me.DeduccionesconfigTableAdapter.Fill(Me.DbFireAndIceDataSet.deduccionesconfig)
            DeduccionesconfigBindingNavigatorSaveItem.PerformClick()
        End If
      
  

    End Sub

    Private Sub agregar_Click(sender As System.Object, e As System.EventArgs) Handles agregar.Click
        guardar.Enabled = True
        agregar.Enabled = False
        GroupControl1.Enabled = True
        GroupControl2.Enabled = True

        Me.DeduccionesconfigTableAdapter.Fill(Me.DbFireAndIceDataSet.deduccionesconfig)
     

    End Sub

    Private Sub IhssestadoCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IhssestadoCheckBox.CheckedChanged
        If IhssestadoCheckBox.CheckState = CheckState.Checked Then
            IhssTextEdit.Properties.ReadOnly = False
        Else
            IhssTextEdit.Properties.ReadOnly = True
        End If

    End Sub

    Private Sub FosoviestadoCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FosoviestadoCheckBox.CheckedChanged
        If FosoviestadoCheckBox.CheckState = CheckState.Checked Then
            FosoviTextEdit.Properties.ReadOnly = False
        Else
            FosoviTextEdit.Properties.ReadOnly = True
        End If
    End Sub

    Private Sub RapestadoCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RapestadoCheckBox.CheckedChanged
        If RapestadoCheckBox.CheckState = CheckState.Checked Then
            RapTextEdit.Properties.ReadOnly = False
        Else
            RapTextEdit.Properties.ReadOnly = True
        End If
    End Sub

    Private Sub IsrestadoCheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IsrestadoCheckBox.CheckedChanged
        If IsrestadoCheckBox.CheckState = CheckState.Checked Then
            IsrTextEdit.Properties.ReadOnly = False
        Else
            IsrTextEdit.Properties.ReadOnly = True


        End If
    End Sub
End Class